<template>
  <div class="width-style">
    <LevelOnePageTop moduleName="疾病预防篇" :catagoryList="catagoryList"/>
    <el-row :gutter="20">
      <el-col :span="18">
        <div class="grid-content">
          <InnerModuleLong innerModuleName="预防常识" :list="commonList"  :picSrc="require('@/assets/images/preventionCommonsense.jpg')" routeName="/prevention/commonsense"/>
          <InnerModuleLong innerModuleName="常见传染病" :list="illnessList"  :picSrc="require('@/assets/images/preventionContagion.jpg')" routeName="/prevention/contagion"/>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">
          <ModuleAdviser :doctorList="doctorList"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import LevelOnePageTop from '@/components/levelOnePageTop'
import {renderTime} from '@/utils/tools.js'
export default {
  name: "Prevention",
  layout: "homeLayout",
  components: { LevelOnePageTop },
  async asyncData({app}) {
    //获取当前类下的最热文章
    let res = await app.api.reqGeneralAllByCatalogue(8);
    if (res.code === 200) {
      for (let item of res.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
     //获取医生等列表
    let doctorRes=await app.api.reqAllDoctor();
    if(doctorRes.code===200){
      for(let doctor of doctorRes.rows){
        doctor.doctorAvatar=app.api.BASEURL+doctor.doctorAvatar
      }
    }
    //获取当类下的子分类的文章
    // let commonRes = await app.api.reqGeneralAllByCatalogue(25);//预防常识
    // if (commonRes.code === 200) {
    //   for (let item of commonRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let commonRes1 = await app.api.reqCoreGeneralByPage(89,1,3);
    let commonRes2 = await app.api.reqCoreGeneralByPage(90,1,3);
    let commonList
    if (commonRes1.code === 200&&commonRes2.code===200) {
      commonList=commonRes1.rows.concat(commonRes2.rows)
      for (let item of commonList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    // let illnessRes = await app.api.reqGeneralAllByCatalogue(26);//常见传染病
    // if (illnessRes.code === 200) {
    //   for (let item of illnessRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let illnessRes1 = await app.api.reqCoreGeneralByPage(95,1,3);
    let illnessRes2 = await app.api.reqCoreGeneralByPage(96,1,3);
    let illnessList
    if (illnessRes1.code === 200&&illnessRes2.code===200) {
      illnessList=illnessRes1.rows.concat(illnessRes2.rows)
      for (let item of illnessList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    return {
      catagoryList:res.rows,
      doctorList:doctorRes.rows,
      // commonList:commonRes.rows,
      // illnessList:illnessRes.rows,
      commonList,
      illnessList,
    }
  },
};
</script>

<style scoped lang="less">
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.module-name {
  font-size: 20px;
  .icon-traditional {
    font-size: 24px;
    color: @themeColor;
  }
}
.modern-medical-img {
  width: 100%;
  height: 100%;
}
</style>

